package com.tanhua.server.controller;

import com.tanhua.model.vo.PageResult;
import com.tanhua.server.server.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import sun.java2d.pipe.RegionSpanIterator;

import java.util.Map;

@RestController
@RequestMapping("/messages")
public class MessagesController {
@Autowired
private MessageService messageService;
    @PostMapping("/contacts") //联系人添加
    public ResponseEntity contacts(@RequestBody Map map){
        String string = map.get("userId").toString();
        Long userId = Long.valueOf(string);
        messageService.contacts(userId);
        return ResponseEntity.ok(null);
    }
    @GetMapping("/contacts") //查询联系人列表
    public ResponseEntity friendList(@RequestParam(defaultValue = "10") Integer pageSize,
                                     @RequestParam(defaultValue = "1") Integer page){
      PageResult pageResult = messageService.friendPage(page,pageSize);
      return ResponseEntity.ok(pageResult);
    }
}
